// <copyright file="YUILibraryItem.cs" company="YUIAsp.Net">
// Copyright (c) 2009 All Right Reserved
// </copyright>
// <author>raul popescu</author>
// <email>dev@yuiasp.net</email>
// <date>2009-01-30</date>
// <summary>YUIAsp.Net File</summary>

using System;
using System.ComponentModel;
using System.Web.UI;

namespace YUIAspNet.Common
{
    [ToolboxItem(false)]
    internal class YUILibraryItem
    {
        private YUIScriptName _scriptName;

        internal YUILibraryItem(YUIScriptName scriptName)
        {
            _scriptName = scriptName;
        }

        internal string GetScriptName(ScriptMode scriptMode)
        {
            switch (this._scriptName)
            {
                case YUIScriptName.Yahoo:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.YAHOO_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.YAHOO;
                    return YUIScriptDependencyResolver.YAHOO_MIN;

                case YUIScriptName.ColorPicker:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.COLORPICKER_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.COLORPICKER;
                    return YUIScriptDependencyResolver.COLORPICKER_MIN;

                case YUIScriptName.Dom:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.DOM_DEBUG;
                    
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.DOM;
                    
                        return YUIScriptDependencyResolver.DOM_MIN;

                case YUIScriptName.Animation:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.ANIMATION_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.ANIMATION;
                    return YUIScriptDependencyResolver.ANIMATION_MIN;

                case YUIScriptName.DragDrop:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.DRAGDROP_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.DRAGDROP;
                    return YUIScriptDependencyResolver.DRAGDROP_MIN;

                case YUIScriptName.Container:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.CONTAINER_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.CONTAINER;
                    return YUIScriptDependencyResolver.CONTAINER_MIN;

                case YUIScriptName.Menu:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.MENU_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.MENU;
                    return YUIScriptDependencyResolver.MENU_MIN;

                case YUIScriptName.Element:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.ELEMENT_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.ELEMENT;
                    return YUIScriptDependencyResolver.ELEMENT_MIN;

                case YUIScriptName.Event:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.EVENT_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.EVENT;
                    return YUIScriptDependencyResolver.EVENT_MIN;

                case YUIScriptName.Logger:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.LOGGER_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.LOGGER;
                    return YUIScriptDependencyResolver.LOGGER_MIN;

                case YUIScriptName.Slider:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.SLIDER_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.SLIDER;
                    return YUIScriptDependencyResolver.SLIDER_MIN;

                case YUIScriptName.Button:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.BUTTON_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.BUTTON;
                    return YUIScriptDependencyResolver.BUTTON_MIN;

                case YUIScriptName.TreeView:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.TREEVIEW_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.TREEVIEW;
                    return YUIScriptDependencyResolver.TREEVIEW_MIN;

                case YUIScriptName.TabView:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.TABVIEW_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.TABVIEW;
                    return YUIScriptDependencyResolver.TABVIEW_MIN;

                case YUIScriptName.AutoComplete:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.AUTOCOMPLETE_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.AUTOCOMPLETE;
                    return YUIScriptDependencyResolver.AUTOCOMPLETE_MIN;

                case YUIScriptName.DataSource:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.DATASOURCE_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.DATASOURCE;
                    return YUIScriptDependencyResolver.DATASOURCE_MIN;

                case YUIScriptName.Connection:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.CONNECTION_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.CONNECTION;
                    return YUIScriptDependencyResolver.CONNECTION_MIN;

                case YUIScriptName.Charts:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.CHARTS_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.CHARTS;
                    return YUIScriptDependencyResolver.CHARTS_MIN;

                case YUIScriptName.Calendar:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.CALENDAR_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.CALENDAR;
                    return YUIScriptDependencyResolver.CALENDAR_MIN;

                case YUIScriptName.RichTextEditor:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.EDITOR_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.EDITOR;
                    return YUIScriptDependencyResolver.EDITOR_MIN;

                case YUIScriptName.Json:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.JSON_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.JSON;
                    return YUIScriptDependencyResolver.JSON_MIN;

                case YUIScriptName.DataTable:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.DATATABLE_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.DATATABLE;
                    return YUIScriptDependencyResolver.DATATABLE_MIN;

                case YUIScriptName.Paginator:
                    if (scriptMode == ScriptMode.Debug)
                        return YUIScriptDependencyResolver.PAGINATOR_DEBUG;
                    if (scriptMode == ScriptMode.Raw)
                        return YUIScriptDependencyResolver.PAGINATOR;
                    return YUIScriptDependencyResolver.PAGINATOR_MIN;
                    
                case YUIScriptName.YahooDomEvent:
                     return YUIScriptDependencyResolver.YAHOO_DOM_EVENT;

                case YUIScriptName.Layout:
                     if (scriptMode == ScriptMode.Debug)
                         return YUIScriptDependencyResolver.LAYOUT_DEBUG;
                     if (scriptMode == ScriptMode.Raw)
                         return YUIScriptDependencyResolver.LAYOUT;
                     return YUIScriptDependencyResolver.LAYOUT_MIN;

                case YUIScriptName.Resize:
                     if (scriptMode == ScriptMode.Debug)
                         return YUIScriptDependencyResolver.RESIZE_DEBUG;
                     if (scriptMode == ScriptMode.Raw)
                         return YUIScriptDependencyResolver.RESIZE;
                     return YUIScriptDependencyResolver.RESIZE_MIN;

                default:
                    throw new ArgumentException("YUIScriptName not recognized! ", _scriptName.ToString());
            }
        }

        internal ScriptReference GetScriptReference(ScriptMode scriptMode)
        {
            return new ScriptReference(GetScriptName(scriptMode), this.GetType().Assembly.FullName);
        }
    }
}
